package com.lee.dutylower;

import android.support.test.runner.AndroidJUnit4;

import com.lee.dutylower.db.greenEntity.PostRecord;
import com.lee.dutylower.db.greenEntity.Soldier;
import com.lee.dutylower.db.greendao.PostRecordDao;
import com.lee.dutylower.db.greendao.SoldierDao;
import com.lee.dutylower.utils.LogUtils;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Instrumentation test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ScheduleTest {
    @Test
    public void useAppContext() throws Exception {
        PostRecordDao postRecordDao = MyApplication.getApplication().getDaoSession().getPostRecordDao();
        // Context of the app under test.
        List<PostRecord> noon = postRecordDao.queryBuilder().where(PostRecordDao.Properties.TimesID.eq(1l), PostRecordDao.Properties.SentryID.between(13l,15l), PostRecordDao.Properties.Dayofweek.eq(1)).build().list();
        List<Soldier> set = new ArrayList<>();
        //新建集合 当士兵被分配后就从里面删除
        for (PostRecord postRecord : noon) {
            set.add(postRecord.getSoldier());
        }
        SoldierDao soldierDao = MyApplication.getApplication().getDaoSession().getSoldierDao();
        List<Soldier> list = soldierDao.queryBuilder().where(SoldierDao.Properties.SquadID.eq(2l)).build().list();
        for (int i = 0; i < list.size(); i++) {
            for (int i1 = 0; i1 < list.get(i).getSentryGroup().size(); i1++) {
                if (i%2 == 0 && i1%2 == 0){
                    list.get(i).getSentryGroup().remove(i1);
                }
            }
        }
        LogUtils.e("NScheduleTask",list.toString());
        Collections.sort(list);
        LogUtils.e("NScheduleTask",list.toString());
        Collections.sort(list);
        LogUtils.e("NScheduleTask",list.toString());

    }
}
